const path = require( 'path' );
const HtmlWebpackPlugin = require( 'html-webpack-plugin' );
const { VueLoaderPlugin } = require( 'vue-loader' )
const CssMinimizerPlugin = require( 'css-minimizer-webpack-plugin' )
module.exports = {
  mode: 'development',
  devtool: 'source-map',
  entry: path.resolve( __dirname, 'main.ts' ),
  output: {
    path: path.resolve( __dirname, '../website-dist' ),
    filename: 'bundle.js'
  },
  devServer: {
    historyApiFallback: true,
    inline: true,
    hot: true,
    port: 8989,
    open: true,
    overlay: true
  },
  optimization: {
    minimize: true,
    minimizer: [ new CssMinimizerPlugin() ],
  },
  resolve: { // 解析模块 对应的扩展名有哪些
    extensions: [ '.ts', '.tsx', '.js', '.vue' ]
  },
  module: {
    rules: [ {
      test: /\.(ts|js)x?$/,
      exclude: /node_modules/,
      loader: 'babel-loader'
    },
    {
      test: /\.vue$/,
      loader: 'vue-loader'
    },
    {
      test: /\.(svg|otf|ttf|woff|woff2|eot|gif|png)$/,
      loader: 'url-loader'
    },
    {
      test: /\.(scss|css)/,
      use: [  // loader 三种写法  { }  ""  []
        'style-loader',
        'css-loader',
        'sass-loader'
      ]
    }
    ]
  },
  plugins: [
    new VueLoaderPlugin(),
    new HtmlWebpackPlugin( {
      template: path.resolve( __dirname, 'index.html' )
    } )

  ]
}
